package org.csu.pet_store_back.web;

import jakarta.annotation.Resource;
import org.csu.pet_store_back.domain.AlipayVo;
import org.csu.pet_store_back.service.PayService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;

@CrossOrigin
@RestController
public class PayController {
    @Resource
    private PayService payService;

    /**
     * 点击支付
     * */
    @RequestMapping("/Alipay")
    public Object pay(
            @RequestBody AlipayVo alipayVo
    ) throws Exception{
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMDD HHmmss");
        System.out.println(dateFormat.format(date));
        System.out.println("支付成功");
        return payService.Alipay(alipayVo);
    }
}
